Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#1032 working veto system #1033

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

K-ETFreeman
Copy link

@K-ETFreeman K-ETFreeman commented Dec 6, 2024

Working on #1032
I need some feedback, what is right, what is wrong, what needs to be changed, etc

@Sheikah45 Sheikah45 requested a review from Askaholic December 6, 2024 19:02
Comment on lines +549 to +550
if (tokensTotalPerPlayer[player.id] > veto_tokens_per_player):
raise RuntimeError(f"Player {player.id} has too many vetoes!")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not do validation of the number of tokens per player when starting the game. This validation and error raising should happen when the server receives the set_vetoes message. This is because as it is now a player could send the server more than the max amount of vetoes and then cause a game to never be able to launch.

Comment on lines +705 to +723
def calculate_dynamic_tokens_per_map(self, M: float, tokens: list[int]) -> float:
sorted_tokens = sorted(tokens)
if (sorted_tokens.count(0) >= M):
return 1

result = 1; last = 0; index = 0
while (index < len(sorted_tokens)):
(index, last) = next(((i, el) for i, el in enumerate(sorted_tokens) if el > last), (len(sorted_tokens) - 1, sorted_tokens[-1]))
index += 1
divider = index - M
if (divider <= 0):
continue

result = sum(sorted_tokens[:index]) / divider
upperLimit = sorted_tokens[index] if index < len(sorted_tokens) else float('inf')
if (result <= upperLimit):
return result

raise Exception("Failed to calculate dynamic tokens per map: impossible vetoes setup")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here we are throwing an exception based on user input so a user could craft a veto selection that could cause the majority of games to fail to start. It would be better to have some default value rather than throwing an exception.

@K-ETFreeman
Copy link
Author

K-ETFreeman commented Dec 6, 2024

also idk how least_common should work
currently set just X2 multiplier if map is least_played and not vetoed by anyone
but we can set to X5 or X10, it seems really harmless
but maybe not, depends how exactly this history works, is it being reset or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants